<template>
  <div class="settings">
    <van-nav-bar safe-area-inset-top placeholder :title="$t('AdvancedSetting')" left-arrow fixed @click-left="onClickLeft" />
    <van-pull-refresh v-model="isLoading" :pulling-text="$t('PullingText')" :loosing-text="$t('PullingText')" :success-text="$t('refreshSuccee')" @refresh="onRefresh">
       <van-collapse class="marginTop15" v-model="activeNames">
        <van-collapse-item :title="$t('Safety')" name="1">
          <safetyPTVue :deviceType="14" :safety="safety" :reg="61" :key="timer" @getFormData="setSafety"></safetyPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Grid')" name="2">
          <vacMaxPTVue :setName="$t('UnderVoltage_L2')" :setUntil="'V'" :setMin="'0.0'" :setMax="'300.0'" :setValue.sync="LocalArr.VacMinValue" :reg="1"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('OverVoltage_L2')" :setUntil="'V'" :setMin="'150.0'" :setMax="'300.0'" :setValue.sync="LocalArr.VacMaxValue" :reg="2"></vacMaxPTVue>
          <facMaxPTVue :setName="$t('UnderFreq_L2')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'65.00'" :setValue.sync="LocalArr.FacMinValue" :reg="3"></facMaxPTVue>
          <facMaxPTVue :setName="$t('OverFreq_L2')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'65.00'" :setValue.sync="LocalArr.FacMaxValue" :reg="4"></facMaxPTVue>
          <vacMaxPTVue :setName="$t('Vac10MAvg')" :setUntil="'V'" :setMin="'150.0'" :setMax="'300.0'" :setValue.sync="LocalArr.Grid10MinAverageValue" :reg="5" v-if="safety==1||safety==4||safety==5||safety==9||safety==23"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('UnderVoltage_L1')" :setUntil="'V'" :setMin="'0.0'" :setMax="'300.0'" :setValue.sync="LocalArr.VacMinSlowProtectValue" :reg="6" v-if="safety!=4&&safety!=23&&safety!=25"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('OverVoltage_L1')" :setUntil="'V'" :setMin="'150.0'" :setMax="'300.0'" :setValue.sync="LocalArr.VacMaxSlowProtectValue" :reg="7" v-if="safety!=4&&safety!=5&&safety!=25"></vacMaxPTVue>
          <facMaxPTVue :setName="$t('UnderFreq_L1')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'65.00'" :setValue.sync="LocalArr.FacMinSlowProtectValue" :reg="8" v-if="safety!=1&&safety!=5&&safety!=23"></facMaxPTVue>
          <facMaxPTVue :setName="$t('OverFreq_L1')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'65.00'" :setValue.sync="LocalArr.FacMaxSlowProtectValue" :reg="9" v-if="safety!=1&&safety!=4&&safety!=5&&safety!=23&&safety!=25"></facMaxPTVue>
          <pfLockInPointPTVue :setName="$t('Tuvp_L2')" :setUntil="'10Ms'" :setMin="2" :setMax="2000" :setValue.sync="LocalArr.TimeVacMinFastAdjValue" :reg="10" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==27||safety==33"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('Tovp_L2')" :setUntil="'10Ms'" :setMin="2" :setMax="2000" :setValue.sync="LocalArr.TimeVacMaxFastAdjValue" :reg="11" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==27||safety==33"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('Tufp_L2')" :setUntil="'10Ms'" :setMin="2" :setMax="2000" :setValue.sync="LocalArr.TimeFacMinFastAdjValue" :reg="12" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==25||safety==27||safety==33"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('Tofp_L2')" :setUntil="'10Ms'" :setMin="2" :setMax="2000" :setValue.sync="LocalArr.TimeFacMaxFastAdjValue" :reg="13" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==25||safety==27||safety==33"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('Tuvp_L1')" :setUntil="'10Ms'" :setMin="2" :setMax="10000" :setValue.sync="LocalArr.TimeVacMinSlowAdjValue" :reg="14" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==27||safety==33"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('Tovp_L1')" :setUntil="'10Ms'" :setMin="2" :setMax="10000" :setValue.sync="LocalArr.TimeVacMaxSlowAdjValue" :reg="15" v-if="safety==1||safety==9||safety==10||safety==23||safety==27||safety==33"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('Tufp_L1')" :setUntil="'10Ms'" :setMin="2" :setMax="10000" :setValue.sync="LocalArr.TimeFacMinSlowAdjValue" :reg="16" v-if="safety==4||safety==9||safety==10||safety==25||safety==27||safety==33"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('Tofp_L1')" :setUntil="'10Ms'" :setMin="2" :setMax="10000" :setValue.sync="LocalArr.TimeFacMaxSlowAdjValue" :reg="17" v-if="safety==9||safety==10||safety==27||safety==33"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('ReConnectionTime')" :setUntil="'S'" :setMin="15" :setMax="600" :setValue.sync="LocalArr.ReconnectionTimeValue" :reg="18"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('CheckingTime')" :setUntil="'S'" :setMin="15" :setMax="1000" :setValue.sync="LocalArr.CheckingTimeValue" :reg="19" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==27||safety==33"></pfLockInPointPTVue>
          <van-divider>OFPL_Setting</van-divider>
          <languagePTVue v-if="safety==23||safety==25||safety==33"
            :setName="'OFPL_Curve'"
            :columns="OFPLCurveArr"
            :setValue="LocalArr.OFPLCurveValue"
            :reg="91"
            @getFormData="setOFPL_Curve"
          ></languagePTVue>
          <facMaxPTVue :setName="$t('OFPL_RemovePoint')" :setUntil="'Hz'" :setMin="'50.00'" :setMax="LocalArr.ofplStartPointValue" :setValue.sync="LocalArr.ofplRemovePointValue" :reg="92" v-if="isOFPL_Curve&&(safety==9||safety==10||safety==23||safety==25||safety==33)"></facMaxPTVue>
          <facMaxPTVue :setName="$t('OFPL_StartPoint')" :setUntil="'Hz'" :setMin="'50.10'" :setMax="'52.00'" :setValue.sync="LocalArr.ofplStartPointValue" :reg="93" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33"></facMaxPTVue>
          <pfLockInPointPTVue :setName="$t('OFPL_DropRate')" :setUntil="'%'" :setMin="2" :setMax="12" :setValue.sync="LocalArr.ofplSetRateValue" :reg="94" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33"></pfLockInPointPTVue>
          <vacMaxPTVue :setName="$t('OFPL_DelayTime')" :setUntil="'S'" :setMin="'0.0'" :setMax="'10.0'" :setValue.sync="LocalArr.ofplDelayTimeValue" :reg="95" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33"></vacMaxPTVue>
          <setWgraPTVue :setName="$t('SetWgra')" :setUntil="'%'" :setMin="'0.0500'" :setMax="'1.0000'" :setValue.sync="LocalArr.SetWgraValue" :reg="96" v-if="safety==100"></setWgraPTVue>
          <pfLockInPointPTVue :setName="'OFPL_TStop'" :setUntil="'S'" :setMin="0" :setMax="600" :setValue.sync="LocalArr.ofplTStopValue" :reg="131" v-if="safety==9||safety==23||safety==25||safety==33"></pfLockInPointPTVue>
          <van-divider>UFPL_Setting </van-divider>
          <facMaxPTVue :setName="$t('UFPL_RemovePoint')" :setUntil="'Hz'" :setMin="'49.50'" :setMax="'50.00'" :setValue.sync="LocalArr.ufplRemovePointValue" :reg="97" v-if="safety==9"></facMaxPTVue>
          <facMaxPTVue :setName="$t('UFPL_StartPoint')" :setUntil="'Hz'" :setMin="'47.00'" :setMax="'49.90'" :setValue.sync="LocalArr.ufplStartPointValue" :reg="98" v-if="safety==9||safety==23||safety==25||safety==33"></facMaxPTVue>
          <pfLockInPointPTVue :setName="$t('UFPL_DropRate')" :setUntil="'%'" :setMin="2" :setMax="12" :setValue.sync="LocalArr.ufplSetRateValue" :reg="99" v-if="safety==9||safety==23||safety==25||safety==33"></pfLockInPointPTVue>
          <vacMaxPTVue :setName="$t('UFPL_DelayTime')" :setUntil="'S'" :setMin="'0.0'" :setMax="'10.0'" :setValue.sync="LocalArr.ufplDelayTimeValue" :reg="100" v-if="safety==1||safety==9||safety==23||safety==25||safety==33"></vacMaxPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('ExportControl')" name="3">
          <pfLockInPointPTVue :setName="$t('UserValue')" :setUntil="'10W'" :setMin="0" :setMax="60000" :setValue.sync="LocalArr.ExportLimitValue" :reg="48"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('MeterCTSettings')" name="4">
          <languagePTVue
            :setName="$t('ModeSelect')"
            :columns="meterArr"
            :setValue="LocalArr.MeterModeCode"
            :reg="109"
            @getFormData="setMeterMode"
          ></languagePTVue>
          <languagePTVue v-if="isMeter"
            :setName="$t('Meter')"
            :columns="toggleArr"
            :setValue="LocalArr.MeterEnableCode"
            :reg="113"
            @getFormData="setMeterEnable"
          ></languagePTVue>
          <pfLockInPointPTVue :setName="$t('Meter1ID')" :setMin="1" :setMax="200" :setValue.sync="LocalArr.Meter1IDValue" :reg="110" v-if="isMeter&&isMeterEable"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('Meter2ID')" :setMin="1" :setMax="200" :setValue.sync="LocalArr.Meter2IDValue" :reg="111"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item title="Shadow Fix" name="5">
          <languagePTVue :columns="scanModeArr" :setValue="LocalArr.ScanModeValue" :reg="106"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item title="Modbus" name="6">
          <languagePTVue :setName="'Braud Rate'" :columns="modbusArr" :setValue="LocalArr.ModbusValue" :reg="103"></languagePTVue>
          <pfLockInPointPTVue :setName="$t('Address')" :setMin="1" :setMax="255" :setValue.sync="LocalArr.ModbusAddressValue" :reg="102"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item title="Mate Box Setting" name="7">
          <languagePTVue :columns="toggleArr" :setValue="LocalArr.MateBoxValue" :reg="105"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('PowerFactor')" name="8" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==27||safety==28||safety==33">
          <van-form @submit="powerfactorSubmit">
            <van-field :value="LocalArr.factMode" :label="$t('ModeSelect')" readonly clickable name="picker" input-align="right" @click="showPowerFact = true" />
            <van-popup v-model="showPowerFact" round position="bottom">
              <van-picker show-toolbar :columns="powerFactors" 
                @cancel="showPowerFact = false" 
                @confirm="factModeConfirm" 
                :confirm-button-text="$t('OK')"
                :cancel-button-text="$t('Cancel')" 
              />
            </van-popup>
            <van-field v-if="(factModeCode==1||factModeCode==2)&&(safety==1||safety==4||safety==5||safety==23||safety==25||safety==27||safety==28||safety==33)" 
              v-model="LocalArr.P2Value" 
              :label="$t('PFValue')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo1,message: `${$t('Range')}：0.80-1.00` }]" 
            />
            <van-field v-if="factModeCode==3&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33)"
              v-model="LocalArr.P3Value" 
              :label="$t('P4_PF')"  
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo2,message: `${$t('Range')}：0.90-1.00` }]" 
            />
            <van-field v-if="factModeCode==3&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33)"
              v-model="LocalArr.P4Value" 
              :label="$t('P3_PF')"
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo2,message: `${$t('Range')}：0.90-1.00` }]" 
            />
            <van-field v-if="factModeCode==3&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33)"
              v-model="LocalArr.P5Value" 
              :label="$t('Power4')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo3,message: `${$t('Range')}：0.00-1.00` }]" 
            />
            <van-field v-if="factModeCode==3&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33)"
              v-model="LocalArr.P6Value" 
              :label="$t('Power3')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo3,message: `${$t('Range')}：0.00-1.00` }]" 
            />
            <div class="factorBtnBox">
              <van-button block round>{{$t('Save')}}</van-button>
            </div>
          </van-form>
          <facMaxPTVue :setName="'P1_PF'" :setMin="'0.90'" :setMax="'1.00'" :setValue.sync="LocalArr.P1PFValue" :reg="125" v-if="isPFP&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33)"></facMaxPTVue>
          <facMaxPTVue :setName="'P2_PF'" :setMin="'0.90'" :setMax="'1.00'" :setValue.sync="LocalArr.P2PFValue" :reg="124" v-if="isPFP&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33)"></facMaxPTVue>
          <facMaxPTVue :setName="'Power1'" :setMin="'0.00'" :setMax="'1.00'" :setValue.sync="LocalArr.Power1Value" :reg="127" v-if="isPFP&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33)"></facMaxPTVue>
          <facMaxPTVue :setName="'Power2'" :setMin="'0.00'" :setMax="'1.00'" :setValue.sync="LocalArr.Power2Value" :reg="126" v-if="isPFP&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33)"></facMaxPTVue>
          <pfLockInPointPTVue :setName="'PfLockInPoint'" :setUntil="'%'" :setMin="105" :setMax="110" :setValue.sync="LocalArr.PfLockInPointValue" :reg="68" v-if="isPFP&&(safety==9||safety==10||safety==23||safety==25||safety==33)"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="'PfLockOutPoint'" :setUntil="'%'" :setMin="90" :setMax="98" :setValue.sync="LocalArr.PfLockOutPointValue" :reg="69" v-if="isPFP&&(safety==9||safety==10||safety==23||safety==25||safety==33)"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="'3Tau'" :setUntil="'S'" :setMin="3" :setMax="180" :setValue.sync="LocalArr.tauValue" :reg="130" v-if="isPFP&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33)"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('SetQurangeV1')" :setUntil="'%'" :setMin="0" :setMax="60" :setValue.sync="LocalArr.SetQurangeV1Value" :reg="70" v-if="isQu&&safety==100"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('SetQurangeV4')" :setUntil="'%'" :setMin="0" :setMax="60" :setValue.sync="LocalArr.SetQurangeV4Value" :reg="71" v-if="isQu&&safety==100"></pfLockInPointPTVue>
          <vacMaxPTVue :setName="$t('QuResponseV1')" :setUntil="'V'" :setMin="'195.0'" :setMax="'225.0'" :setValue.sync="LocalArr.QuResponseV1Value" :reg="72" v-if="isQu&&(safety==4||safety==5||safety==23||safety==25||safety==33)"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('QuResponseV2')" :setUntil="'V'" :setMin="'216.0'" :setMax="'230.0'" :setValue.sync="LocalArr.QuResponseV2Value" :reg="73" v-if="isQu&&(safety==4||safety==5||safety==23||safety==25||safety==33)"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('QuResponseV3')" :setUntil="'V'" :setMin="'235.0'" :setMax="'255.0'" :setValue.sync="LocalArr.QuResponseV3Value" :reg="74" v-if="isQu&&(safety==4||safety==5||safety==23||safety==25||safety==33)"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('QuResponseV4')" :setUntil="'V'" :setMin="'244.0'" :setMax="'265.0'" :setValue.sync="LocalArr.QuResponseV4Value" :reg="75" v-if="isQu&&(safety==4||safety==5||safety==23||safety==25||safety==33)"></vacMaxPTVue>
          <languagePT2Vue :setName="'K'" :columns="KArr" :setValue="LocalArr.kValue" :reg="76" :pre="10" v-if="isQu&&safety==100"></languagePT2Vue>
          <pfLockInPointPTVue :setName="'3Tau'" :setUntil="'S'" :setMin="6" :setMax="180" :setValue.sync="LocalArr.ReactiveDelayTimeValue" :reg="77" v-if="isQu&&(safety==1||safety==4||safety==5||safety==23||safety==25||safety==33)"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('QuDelayTimer')" :setUntil="'S'" :setMin="0" :setMax="30" :setValue.sync="LocalArr.QuDelayTimerValue" :reg="78" v-if="isQu&&safety==100"></pfLockInPointPTVue>
          <languagePTVue
            :setName="'QuLockEn'"
            :columns="toggleArr"
            :setValue="LocalArr.QuLockEnCode"
            :reg="146"
            @getFormData="setQuLockEn"
          ></languagePTVue>
          <facMaxPTVue :setName="'QuLockIn'" :setMin="'0.00'" :setMax="'0.20'" :setValue.sync="LocalArr.QuLockInValue" :reg="128" v-if="isQuLockEn&&isQu&&(safety==23||safety==25||safety==33)"></facMaxPTVue>
          <facMaxPTVue :setName="'QuLockOut'" :setMin="'0.00'" :setMax="'0.20'" :setValue.sync="LocalArr.QuLockOutValue" :reg="129" v-if="isQuLockEn&&isQu&&(safety==23||safety==25||safety==33)"></facMaxPTVue>
          <pfLockInPointPT2Vue :setName="$t('bQpower_set')" :setUntil="'10Var'" :setMin="bQpowerMin" :setMax="bQpowerMax" :setValue.sync="LocalArr.bQpower_setValue" :reg="79" v-if="isQSet&&(safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==27||safety==28||safety==33)"></pfLockInPointPT2Vue>
        </van-collapse-item>
        <van-collapse-item :title="$t('puFunction')" name="9" v-if="safety==4||safety==5||safety==9||safety==23||safety==25||safety==33">
          <languagePTVue
            :setName="$t('puFunction')"
            :columns="toggleArr"
            :setValue="LocalArr.puFunctionEnableCode"
            :reg="82"
            @getFormData="setPuFunction"
          ></languagePTVue>
          <vacMaxPTVue :setName="$t('SetV1')" :setUntil="'V'" :setMin="'207.0'" :setMax="'276.0'" :setValue.sync="LocalArr.SetV1Value" :reg="83" v-if="isPu"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('SetV2')" :setUntil="'V'" :setMin="'207.0'" :setMax="'276.0'" :setValue.sync="LocalArr.SetV2Value" :reg="84" v-if="isPu"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('SetV3')" :setUntil="'V'" :setMin="'207.0'" :setMax="'276.0'" :setValue.sync="LocalArr.SetV3Value" :reg="85" v-if="isPu"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('SetV4')" :setUntil="'V'" :setMin="'207.0'" :setMax="'276.0'" :setValue.sync="LocalArr.SetV4Value" :reg="86" v-if="isPu"></vacMaxPTVue>
          <pfLockInPointPTVue :setName="$t('Pu_3Tau')" :setUntil="'S'" :setMin="3" :setMax="180" :setValue.sync="LocalArr.Pu_3TauValue" :reg="87" v-if="isPu"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('H/LVRTFunction')" name="10">
          <languagePTVue
            :setName="$t('H/LVRTFunction')"
            :columns="toggleArr" 
            :setValue="LocalArr.HLVRTFunctionValue" 
            :reg="121"
            @getFormData="setHLVRTFunction"
          ></languagePTVue>
          <vacMaxPTVue :setName="'LVRT VacUpper'" :setUntil="'V'" :setMin="'230.0'" :setMax="'276.0'" :setValue.sync="LocalArr.LVRTVacUpperValue" :reg="123" v-if="isHLVRT&&(safety==4||safety==5||safety==23||safety==25||safety==27||safety==28||safety==33)"></vacMaxPTVue>
          <vacMaxPTVue :setName="'LVRT VacLower'" :setUntil="'V'" :setMin="'46.0'" :setMax="'230.0'" :setValue.sync="LocalArr.LVRTVacLowerValue" :reg="122" v-if="isHLVRT&&(safety==4||safety==5||safety==23||safety==25||safety==27||safety==28||safety==33)"></vacMaxPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('ActivePowerLimit')" name="11" v-if="safety==1||safety==4||safety==5||safety==9||safety==10||safety==23||safety==25||safety==33">
          <pfLockInPointPTVue :setName="$t('ActivePowerLimit')" :setUntil="'%'" :setMin="0" :setMax="100" :setValue.sync="LocalArr.powerLimitValue" :reg="101"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item title="DRM Function" name="12" v-if="safety!=1&&safety!=33">
          <languagePTVue :columns="toggleArr" :setValue="LocalArr.DRMFunctionValue" :reg="119"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('ParallelSetting')" name="13" style="display:none;">
          <languagePTVue :columns="ParallelArr" :setValue="LocalArr.ParallelValue" :reg="120"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item title="Main Breaker Limit (A)" name="14">
          <pfLockInPointPTVue :setMin="32" :setMax="100" :setValue.sync="LocalArr.MainBreakerLimitValue" :reg="112"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('PhasePowerBalance')" name="15" style="display:none;">
          <languagePTVue :columns="toggleArr" :setValue="LocalArr.PhasePowerBalanceValue" :reg="117"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('EPS')" name="16">
          <languagePTVue :setName="$t('Frequency')" :columns="offgridfreArr" :setValue="LocalArr.offGridFreValue" :reg="107"></languagePTVue>
          <pfLockInPointPTVue :setName="$t('MinSoc')" :setUntil="'%'" :setMin="10" :setMax="25" :setValue.sync="LocalArr.offGridMinSocValue" :reg="108"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Reset')" name="17">
          <resetINVEnergyPTVue :setName="$t('ClearInverterHistory')" :reg="27"></resetINVEnergyPTVue>
          <resetINVEnergyPTVue :setName="$t('ResetErrorLogs')" :reg="22"></resetINVEnergyPTVue>
          <resetINVEnergyPTVue :setName="$t('RestMeterCT1')" :reg="24"></resetINVEnergyPTVue>
          <resetINVEnergyPTVue :setName="$t('RestMeterCT2')" :reg="25"></resetINVEnergyPTVue>
          <resetINVEnergyPTVue :setName="$t('Restorefactorysettings')" :reg="23"></resetINVEnergyPTVue>
          <resetINVEnergyPTVue :setName="$t('ClearOverloadFault')" :reg="21"></resetINVEnergyPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('NewPassword')" name="18">
          <newPasswordPTVue :setValue.sync="LocalArr.NewPasswordValue" :reg="116"></newPasswordPTVue>
        </van-collapse-item>
      </van-collapse>
    </van-pull-refresh>
  </div>
</template>

<script>
import safetyPTVue from '../../../components/Safety/SafetyPT'
import pfLockInPointPTVue from '../../../components/PfLockInPoint/PfLockInPointPT'
import vacMaxPTVue from '../../../components/VacMax/VacMaxPT'
import facMaxPTVue from '../../../components/FacMax/FacMaxPT'
import freDroopDelayTimePTVue from '../../../components/FreDroopDelayTime/FreDroopDelayTimePT'
import timeVacMinFastAdjPTVue from '../../../components/TimeVacMinFastAdj/TimeVacMinFastAdjPT'
import languagePTVue from '../../../components/Language/LanguagePT'
import languagePT2Vue from '../../../components/Language/Language2PT'
import resetINVEnergyPTVue from '../../../components/ResetINVEnergy/ResetINVEnergyPT'
import newPasswordPTVue from '../../../components/NewPassword/NewPasswordPT'
import setWgraPTVue from '../../../components/SetWgra/SetWgra'
import pfLockInPointPT2Vue from '../../../components/PfLockInPoint/PfLockInPoint2PT'

export default {
  components:{
    safetyPTVue,
    pfLockInPointPTVue,
    vacMaxPTVue,
    facMaxPTVue,
    freDroopDelayTimePTVue,
    timeVacMinFastAdjPTVue,
    languagePTVue,
    languagePT2Vue,
    resetINVEnergyPTVue,
    newPasswordPTVue,
    setWgraPTVue,
    pfLockInPointPT2Vue
  },
  data(){
    return {
      isLoading:false,
      timer:'',
      activeNames:[],
      safety:sessionStorage.getItem('safety'),
      OFPLCurveArr:['Symmetric','Asymmetry'],
      meterArr:['Meter','CT'],
      isMeter:false,
      isMeterEable:false,
      scanModeArr:[this.$t('Off'),this.$t('low'),this.$t('Middle'),this.$t('High')],
      toggleArr:[this.$t('Disable'),this.$t('Enable')],
      modbusArr:['115200','57600','56000','38400','19200','14400','9600'],
      showPowerFact:false,
      factorArr:[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited1'),code:1},{text:this.$t('UnderExcited1'),code:2},{text:this.$t('PF(P)'),code:3},{text:this.$t('Q(u)'),code:4},{text:this.$t('Q-Set'),code:5}],
      powerFactors:[],
      factModeCode:'',
      isPFP:true,
      isQu:true,
      isQSet:true,
      KArr:['-0.1','0.1'],
      bQpowerMin:'',
      bQpowerMax:'',
      isPu:false,
      isHLVRT:false,
      ParallelArr:['Free','Master'],
      offgridfreArr:['50Hz','60Hz'],
      isQuLockEn:false,
      isOFPL_Curve:false,
      LocalArr:{
        VacMinValue:'',
        VacMaxValue:'',
        FacMinValue:'',
        FacMaxValue:'',
        Grid10MinAverageValue:'',
        VacMinSlowProtectValue:'',
        VacMaxSlowProtectValue:'',
        FacMinSlowProtectValue:'',
        FacMaxSlowProtectValue:'',
        TimeVacMinFastAdjValue:'',
        TimeVacMaxFastAdjValue:'',
        TimeFacMinFastAdjValue:'',
        TimeFacMaxFastAdjValue:'',
        TimeVacMinSlowAdjValue:'',
        TimeVacMaxSlowAdjValue:'',
        TimeFacMinSlowAdjValue:'',
        TimeFacMaxSlowAdjValue:'',
        ReconnectionTimeValue:'',
        CheckingTimeValue:'',
        OFPLCurveValue:'',
        ofplRemovePointValue:'',
        ofplStartPointValue:'',
        ofplSetRateValue:'',
        ofplDelayTimeValue:'',
        SetWgraValue:'',
        ofplTStopValue:'',
        ufplRemovePointValue:'',
        ufplStartPointValue:'',
        ufplSetRateValue:'',
        ufplDelayTimeValue:'',
        ExportLimitValue:'',
        MeterModeCode:'',
        MeterEnableCode:'',
        Meter1IDValue:'',
        Meter2IDValue:'',
        ScanModeValue:'',
        ModbusValue:'',
        ModbusAddressValue:'',
        MateBoxValue:'',
        factMode:'',
        P2Value:'',
        P3Value:'',
        P4Value:'',
        P5Value:'',
        P6Value:'',
        P1PFValue:'',
        P2PFValue:'',
        Power1Value:'',
        Power2Value:'',
        PfLockInPointValue:'',
        PfLockOutPointValue:'',
        tauValue:'',
        SetQurangeV1Value:'',
        SetQurangeV4Value:'',
        QuResponseV1Value:'',
        QuResponseV2Value:'',
        QuResponseV3Value:'',
        QuResponseV4Value:'',
        kValue:'',
        ReactiveDelayTimeValue:'',
        QuDelayTimerValue:'',
        QuLockEnCode:'',
        QuLockInValue:'',
        QuLockOutValue:'',
        bQpower_setValue:'',
        puFunctionEnableCode:'',
        SetV1Value:'',
        SetV2Value:'',
        SetV3Value:'',
        SetV4Value:'',
        Pu_3TauValue:'',
        HLVRTFunctionValue:'',
        LVRTVacUpperValue:'',
        LVRTVacLowerValue:'',
        powerLimitValue:'',
        DRMFunctionValue:'',
        ParallelValue:'',
        MainBreakerLimitValue:'',
        PhasePowerBalanceValue:'',
        offGridFreValue:'',
        offGridMinSocValue:'',
        NewPasswordValue:''
      }
    }
  },
  methods: {
    onClickLeft(){
      this.$router.push({path:'/x3hybridg4setlist'});
    },
    factModeConfirm(value,i){
      this.showPowerFact=false;
      this.LocalArr.factMode=value.text;
      this.factModeCode=value.code;
    },
    fixedTwo1(val){
      return this.comm.fixedTwo(val,0.8,1);
    },
    fixedTwo2(val){
      return this.comm.fixedTwo(val,0.9,1);
    },
    fixedTwo3(val){
      return this.comm.fixedTwo(val,0,1);
    },
    async getData(){
      this.comm.loadingShow();
      let datas=await this.SETAPI.setGetDataPT(localStorage.getItem('domain'),{'tokenId':localStorage.getItem('tokenId'),'sn':localStorage.getItem('wifiSN')});
      if(datas.result!=null&&datas.result!="tokenId不合法!"){
        let dataArr = datas.result;
        this.safety=dataArr[60];
        sessionStorage.setItem('safety',this.safety);
        this.LocalArr.VacMinValue=dataArr[0]/10;
        this.LocalArr.VacMaxValue=dataArr[1]/10;
        this.LocalArr.FacMinValue=dataArr[2]/100;
        this.LocalArr.FacMaxValue=dataArr[3]/100;
        this.LocalArr.Grid10MinAverageValue=dataArr[4]/10;
        this.LocalArr.VacMinSlowProtectValue=dataArr[5]/10;
        this.LocalArr.VacMaxSlowProtectValue=dataArr[6]/10;
        this.LocalArr.FacMinSlowProtectValue=dataArr[7]/100;
        this.LocalArr.FacMaxSlowProtectValue=dataArr[8]/100;
        this.LocalArr.TimeVacMinFastAdjValue=dataArr[9];
        this.LocalArr.TimeVacMaxFastAdjValue=dataArr[10];
        this.LocalArr.TimeFacMinFastAdjValue=dataArr[11];
        this.LocalArr.TimeFacMaxFastAdjValue=dataArr[12];
        this.LocalArr.TimeVacMinSlowAdjValue=dataArr[13];
        this.LocalArr.TimeVacMaxSlowAdjValue=dataArr[14];
        this.LocalArr.TimeFacMinSlowAdjValue=dataArr[15];
        this.LocalArr.TimeFacMaxSlowAdjValue=dataArr[16];
        this.LocalArr.ReconnectionTimeValue=dataArr[17];
        this.LocalArr.CheckingTimeValue=dataArr[18];
        this.LocalArr.OFPLCurveValue=dataArr[90];
        /*判断用户的选择*/
        if(this.LocalArr.OFPLCurveValue==1){
          this.isOFPL_Curve=true;
        }else{
          this.isOFPL_Curve=false;
        }
        this.LocalArr.ofplRemovePointValue=dataArr[91]/100;
        this.LocalArr.ofplStartPointValue=dataArr[92]/100;
        this.LocalArr.ofplSetRateValue=dataArr[93];
        this.LocalArr.ofplDelayTimeValue=dataArr[94]/10;
        this.LocalArr.SetWgraValue=dataArr[95]/10000;
        this.LocalArr.ofplTStopValue=dataArr[130];
        this.LocalArr.ufplRemovePointValue=dataArr[96]/100;
        this.LocalArr.ufplStartPointValue=dataArr[97]/100;
        this.LocalArr.ufplSetRateValue=dataArr[98];
        this.LocalArr.ufplDelayTimeValue=dataArr[99]/10;
        this.LocalArr.ExportLimitValue=dataArr[47];
        this.LocalArr.MeterModeCode=dataArr[108];
        /*判断用户的选择*/
        if(this.LocalArr.MeterModeCode==0){
          this.isMeter=true;
        }else{
          this.isMeter=false;
        }
        this.LocalArr.MeterEnableCode=dataArr[112];
        /*判断用户的选择*/
        if(this.LocalArr.MeterEnableCode==1){
          this.isMeterEable=true;
        }else{
          this.isMeterEable=false;
        }
        this.LocalArr.Meter1IDValue=dataArr[109];
        this.LocalArr.Meter2IDValue=dataArr[110];
        this.LocalArr.ScanModeValue=dataArr[105];
        this.LocalArr.ModbusValue=dataArr[102];
        this.LocalArr.ModbusAddressValue=dataArr[101];
        this.LocalArr.MateBoxValue=dataArr[104];
        this.factModeCode=dataArr[61];
        this.LocalArr.factMode=this.factorArr[this.factModeCode].text;
        /*判断用户的选择*/
        if(dataArr[61]==3){
          this.isPFP=true;
        }else{
          this.isPFP=false;
        }
        if(dataArr[61]==4){
          this.isQu=true;
        }else{
          this.isQu=false;
        }
        if(dataArr[61]==5){
          this.isQSet=true;
        }else{
          this.isQSet=false;
        }
        this.LocalArr.P2Value=dataArr[62]/100;
        this.LocalArr.P3Value=dataArr[63]/100;
        this.LocalArr.P4Value=dataArr[64]/100;
        this.LocalArr.P5Value=dataArr[65]/100;
        this.LocalArr.P6Value=dataArr[66]/100;
        this.LocalArr.P1PFValue=dataArr[124]/100;
        this.LocalArr.P2PFValue=dataArr[123]/100;
        this.LocalArr.Power1Value=dataArr[126]/100;
        this.LocalArr.Power2Value=dataArr[125]/100;
        this.LocalArr.PfLockInPointValue=dataArr[67];
        this.LocalArr.PfLockOutPointValue=dataArr[68];
        this.LocalArr.tauValue=dataArr[129];
        this.LocalArr.SetQurangeV1Value=dataArr[69];
        this.LocalArr.SetQurangeV4Value=dataArr[70];
        this.LocalArr.QuResponseV1Value=dataArr[71]/10;
        this.LocalArr.QuResponseV2Value=dataArr[72]/10;
        this.LocalArr.QuResponseV3Value=dataArr[73]/10;
        this.LocalArr.QuResponseV4Value=dataArr[74]/10;
        this.LocalArr.kValue=dataArr[75]/10;
        this.LocalArr.ReactiveDelayTimeValue=dataArr[76];
        this.LocalArr.QuDelayTimerValue=dataArr[77];
        this.LocalArr.QuLockEnCode=dataArr[145];
        /*判断用户的选择*/
        if(this.LocalArr.QuLockEnCode==1){
          this.isQuLockEn=true;
        }else{
          this.isQuLockEn=false;
        }
        this.LocalArr.QuLockInValue=dataArr[127]/100;
        this.LocalArr.QuLockOutValue=dataArr[128]/100;
        this.LocalArr.bQpower_setValue=dataArr[78];
        this.bQpowerMin=this.comm.bit16(0,dataArr[80]);
        this.bQpowerMax=this.comm.bit16(0,dataArr[79]);
        this.LocalArr.puFunctionEnableCode=dataArr[81];
        /*判断用户的选择*/
        if(this.LocalArr.puFunctionEnableCode==1){
          this.isPu=true;
        }else{
          this.isPu=false;
        }
        this.LocalArr.SetV1Value=dataArr[82]/10;
        this.LocalArr.SetV2Value=dataArr[83]/10;
        this.LocalArr.SetV3Value=dataArr[84]/10;
        this.LocalArr.SetV4Value=dataArr[85]/10;
        this.LocalArr.Pu_3TauValue=dataArr[86];
        this.LocalArr.HLVRTFunctionValue=dataArr[120];
        /*判断用户的选择*/
        if(this.LocalArr.HLVRTFunctionValue==1){
          this.isHLVRT=true;
        }else{
          this.isHLVRT=false;
        }
        this.LocalArr.LVRTVacUpperValue=dataArr[122]/10;
        this.LocalArr.LVRTVacLowerValue=dataArr[121]/10;
        this.LocalArr.powerLimitValue=dataArr[100];
        this.LocalArr.DRMFunctionValue=dataArr[118];
        this.LocalArr.ParallelValue=dataArr[119];
        this.LocalArr.MainBreakerLimitValue=dataArr[111];
        this.LocalArr.PhasePowerBalanceValue=dataArr[116];
        this.LocalArr.offGridFreValue=dataArr[106];
        this.LocalArr.offGridMinSocValue=dataArr[107];
        this.LocalArr.NewPasswordValue=this.comm.showPwd(dataArr[115]);
      }else{
        this.comm.tipsShow('InvNoResponse');
      }
    },
    //获取powerfactor列表
    getPowerFactory(){
      this.powerFactors=[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited1'),code:1},{text:this.$t('UnderExcited1'),code:2},{text:this.$t('PF(P)'),code:3},{text:this.$t('Q(u)'),code:4},{text:this.$t('Q-Set'),code:5}];
    },
    //设置安规
    setSafety(data){
      if(data=='success'){
        this.safety=sessionStorage.getItem('safety');
        this.getPowerFactory();
      }
    },
    //设置MeterMode
    setMeterMode(data){
      /*判断用户的选择*/
      if(data==0){
        this.isMeter=true;
      }else{
        this.isMeter=false;
      }
    },
    //设置MeterEnable
    setMeterEnable(data){
      /*判断用户的选择*/
      if(data==1){
        this.isMeterEable=true;
      }else{
        this.isMeterEable=false;
      }
    },
    //设置powerfactor
    async powerfactorSubmit(){
      //处理数据
      let factorData_new={};
      factorData_new.P1Value=this.factModeCode;
      if(this.LocalArr.P2Value!=null&&this.LocalArr.P2Value!=undefined){
        factorData_new.P2Value=this.comm.mulFunction(this.LocalArr.P2Value,100);
      }
      if(this.LocalArr.P3Value!=null&&this.LocalArr.P3Value!=undefined){
        factorData_new.P3Value=this.comm.mulFunction(this.LocalArr.P3Value,100);
      }
      if(this.LocalArr.P4Value!=null&&this.LocalArr.P4Value!=undefined){
        factorData_new.P4Value=this.comm.mulFunction(this.LocalArr.P4Value,100);
      }
      if(this.LocalArr.P5Value!=null&&this.LocalArr.P5Value!=undefined){
        factorData_new.P5Value=this.comm.mulFunction(this.LocalArr.P5Value,100);
      }
      if(this.LocalArr.P6Value!=null&&this.LocalArr.P6Value!=undefined){
        factorData_new.P6Value=this.comm.mulFunction(this.LocalArr.P6Value,100);
      }
      let Datas=[
        {'reg':62,'val':factorData_new.P1Value},
        {'reg':63,'val':factorData_new.P2Value},
        {'reg':64,'val':factorData_new.P3Value},
        {'reg':65,'val':factorData_new.P4Value},
        {'reg':66,'val':factorData_new.P5Value},
        {'reg':67,'val':factorData_new.P6Value}
      ];
      let params={
        'optType':"setReg",
        'sn':localStorage.getItem('wifiSN'),
        'tokenId':localStorage.getItem('tokenId'),
        'num':6,
        'Data':JSON.stringify(Datas)
      };
      this.comm.loadingShow();
      let data = await this.SETAPI.setInvMachinePT(localStorage.getItem('domain'), params);
      if (data.success) {
        this.comm.toastSuccess();
        /*判断用户的选择*/
        if(this.factModeCode==3){
          this.isPFP=true;
        }else{
          this.isPFP=false;
        }
        if(this.factModeCode==4){
          this.isQu=true;
        }else{
          this.isQu=false;
        }
        if(this.factModeCode==5){
          this.isQSet=true;
        }else{
          this.isQSet=false;
        }
      } else {
        this.comm.toastFail();
      }
    },
    //设置QuLockEn
    setQuLockEn(data){
      /*判断用户的选择*/
      if (data == 1) {
        this.isQuLockEn = true;
      } else {
        this.isQuLockEn = false;
      }
    },
    //设置PU Function
    setPuFunction(data){
      /*判断用户的选择*/
      if (data == 1) {
        this.isPu = true;
      } else {
        this.isPu = false;
      }
    },
    //设置HLVRTFunction
    setHLVRTFunction(data){
      if (data == 1) {
        this.isHLVRT = true;
      } else {
        this.isHLVRT = false;
      }
    },
    //设置OFPL_Curve
    setOFPL_Curve(data){
      if (data == 1) {
        this.isOFPL_Curve = true;
      } else {
        this.isOFPL_Curve = false;
      }
    },
    onRefresh(){
      this.isLoading = false;
      this.timer=new Date().getTime();
      for(let i in this.LocalArr){
        this.LocalArr[i]='';
      }
      this.getData();
      this.getPowerFactory();
    }
  },
  mounted(){
    this.getData();
    this.getPowerFactory();
  }
}
</script>

<style scoped lang="less">

</style>
